<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>套餐明细</title>
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate"/>
    <meta http-equiv="Pragma" content="no-cache"/>
    <meta http-equiv="Expires" content="0"/>

    <link rel="stylesheet" href="../default/css/mui.min.css">
    <link rel="stylesheet" href="../default/css/index.css?V=201905221501">
    <link rel="stylesheet" href="../default/css/animat.min.css">

    <style>
        body, html {
            height: 100%;
        }

        .mui-content {
            height: 100%;
        }

        .mui-bar .mui-btn-link {
            color: #fff;
        }

        .mui-bar-nav ~ .mui-content {
            padding-bottom: 50px;
        }

        .mui-table-view-chevron .mui-table-view-cell {
            padding-right: 0;
        }

        .mui-table-view-cell:after {
            height: 0;
            border-bottom: 1px dashed #c8c7cc;
            left: 0px;
        }
        .mui-table-view{
            background: transparent;
        }
    </style>
</head>
<body>


<header class="mui-bar mui-bar-nav">
    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left fff"></a>
    <h1 class="mui-title">套餐明细</h1>
</header>


<div id="pullrefresh" class="mui-content mui-scroll-wrapper">

    <div class="mui-scroll">
        <!--数据列表-->
        <ul class="mui-table-view mui-table-view-chevron craftsman-list-ul" id="index1">
        </ul>
    </div>
</div>



<script src="../default/js/jquery-2.14.js" type="text/javascript" charset="utf-8"></script>
<script src="../default/js/mui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../default/js/cookie.js"></script>
<script src="../default/js/code.js" type="text/javascript" charset="utf-8"></script>
<script src="../default/js/index.js" type="text/javascript" charset="utf-8"></script>
<script src="../default/js/public.js"></script>
<script>

    $(function () {

    })


    mui.init({
        pullRefresh: {
            container: '#pullrefresh',
            up: {
                auto: true,
                contentrefresh: '正在加载...',
                callback: function () {
                    var self = this;
                    queryUserAll();
                }
            }
        }
    });


    var pageNumber;
    function queryUserAll() {
        mui.showLoading("正在加载..", "div");

        var length = $('#index1 .mui-card').length;


        if (length == 0) {
            pageNumber=0;
        } else if (length % 10 == 0) {
            pageNumber = length/10;
        }else{
            pageNumber=parseInt(length/10+1);
        }
        $.ajax({
            url: website + '/FinancingDetailedController/findByUserId',
            type: 'post',
            data: {
                startingNumber: pageNumber,
                userId: userId
            },
            success: function (data) {
                var html = '';
                var financing_state;
                data.data.forEach(function (value) {
                    if(value.financing_state==1){
                        financing_state='发放中';
                    }else{
                        financing_state='已取出';
                    }
                    html+='<div class="mui-card" data-id="'+value.id+'">\n' +
                        '        <div class="mui-card-header">' +
                        '<p>'+financing_state+'</p>' +
                        '<p class="red">发放金额:￥'+value.financing_number+'</p>' +
                        '</div>\n' +
                        '        <div class="mui-card-content">\n' +
                        '          <div class="mui-card-content-inner">\n' +
                        '           <p>套餐周期:'+value.financial_quantity+'</p>' +
                        '           <p>收入金额:￥'+value.financing_total_revenue+'</p>' +
                        '           <p>剩余金额:￥'+value.residual_quantity+'</p>' +
                        '           <p>开始时间:'+value.financing_start_time+'</p>' +
                        '           <p>结束时间:'+value.financing_end_time+'</p>';
                    if(value.take_out_time!=null){
                        html+='           <p>取出时间:'+value.take_out_time+'</p>';
                    }
                    html+='          </div>\n' +
                        '        </div>\n' +
                        '      </div>';

                });
                if (data.data.length == 0) {
                    mui('#pullrefresh').pullRefresh().endPullupToRefresh(true);
                    mui.hideLoading();
                } else if (data.data.length < 10) {
                    $("#index1").append(html);
                    mui('#pullrefresh').pullRefresh().endPullupToRefresh(true);
                    mui.hideLoading();
                } else {
                    $("#index1").append(html);
                    mui.hideLoading();
                    mui('#pullrefresh').pullRefresh().endPullupToRefresh(false);
                }

            },
            error: function () {
                mui.showLoading("发生错误,返回首页..", "div");
                setTimeout(function () {
                    window.location.href = '../../index.html';
                }, 1000)
            }
        })
    }


    mui('body').on('tap', '.mui-card', function (e) {
        var id = this.getAttribute('data-id');
        //打开详情页面
        mui.openWindow({
            url: 'meal-detailed-en.html?menId=' + id
        });
    });



</script>
</body>
</html>